package com.yellowpage.white.util;

import java.io.File;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class SpringContextUtil {
	public static ApplicationContext applicationContext = null;

	public static ApplicationContext getApplicationContext() throws Exception {
		String folder = "conf/";
		
		File classRootFile = BeanUtil
				.getClassPathFile(folder + "applicationContext.xml");

		String[] contextFiles = classRootFile.getParentFile().list(new SpringFileFilter());
		
		String[] resourceFiles = new String[contextFiles.length];
		for(int i = 0; i < contextFiles.length; i++){
			resourceFiles[i] = folder +  contextFiles[i];
		}

		applicationContext = new ClassPathXmlApplicationContext(
				resourceFiles);

		return applicationContext;
	}	
}
